<?php
$g4_path = '../';
require_once ($g4_path.'common.php');
require_once ($g4_path.'lib.php');
require_once ('./teacher.lib.php');

global $cate1, $cate2, $teacher;

$_catesql = "SELECT c.name as v, c.no as n FROM course c, g4_member m WHERE c.teacher='$teacher' AND m.mb_no = c.teacher AND m.mb_division='강사'";
$list1 = fetchAll2($_catesql, $cate1);
array_unshift($list1, array('','--강의명--'));

if($cate1) {
    $_catesql = "SELECT m.mb_name as v, c.student as n FROM course_order c, g4_member m WHERE c.course='$cate1' AND c.student=m.mb_no GROUP BY m.mb_name";
} else {
        $_catesql = "SELECT m.mb_name as v, c.student as n FROM course_order c, g4_member m WHERE c.student=m.mb_no AND m.mb_division='학생' GROUP BY m.mb_name";
}

    $list2 = fetchAll2($_catesql, $cate2);
    array_unshift($list2, array('','--선택해주세요--'));
?>
<script type="text/javascript" src="inc/chain_select.js"></script>
<script type="text/javascript">
var category_data ={
        'cate1':<?php echo json_encode2($list1); ?>,
        'cate2':<?php echo json_encode2($list2); ?>
}
</script>
<script type="text/javascript">
    var category = new ChainSelect(category_data,'inc/teacher_category_list.php');
</script>
